package com.boot.security.server.dao;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.boot.security.server.model.SysSettings;

@Mapper
public interface SysSettingsDao {

    @Select("select * from sys_settings t where t.settingName = #{settingName}")
    SysSettings getByName(String settingName);

    @Delete("delete from sys_settings where id = #{id}")
    int delete(Long id);

    int update(SysSettings sysSettings);
    
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into sys_settings(settingName, settingValue, description) values(#{settingName}, #{settingValue}, #{description})")
    int save(SysSettings sysSettings);
    
    int count(@Param("params") Map<String, Object> params);

    List<SysSettings> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset, @Param("limit") Integer limit);
}
